package com.yl.chainStore.pojo.vo.pay

import com.baomidou.mybatisplus.annotation.TableField
import com.yl.chainStore.common.Constants
import com.yl.chainStore.common.enums.TypeEnum
import com.yl.common.annotation.NoArg
import java.math.BigDecimal
import java.math.RoundingMode

@NoArg
data class BalanceUpdateVo(

	/**
	 * 患者
	 */
	val customerId:Long,

	/**
	 * 金额
	 */
	var money:Long,

	/**
	 * 馈赠金
	 */
	var giftsOfGold:Long = 0,


	/**
	 * 付款类型
	 */
	val payType:TypeEnum = TypeEnum.OTHER,

	/**
	 * 备注
	 */
	val remark:String?=null,

	/**
	 * 收款人（转账用）
	 */
	val toCustomerId:Long?= null,
){
	/**
	 * 单价显示
	 */
	@TableField(exist = false)
	var moneyShow: BigDecimal? = null
		get() {

			if (field == null) {
				return BigDecimal(money.div(Constants.OtherConfig.MONEY_TO_DB_DOUBLE)).setScale(2, RoundingMode.HALF_UP)
			}
			return field
		}
		set(value) {
			if (value != null) {
				money = (value.multiply(BigDecimal(Constants.OtherConfig.MONEY_TO_DB_DOUBLE))).toLong()
				field = value
			}
		}

	/**
	 * 单价显示
	 */
	@TableField(exist = false)
	var giftsOfGoldShow: BigDecimal? = null
		get() {

			if (field == null) {
				return BigDecimal(giftsOfGold.div(Constants.OtherConfig.MONEY_TO_DB_DOUBLE)).setScale(2, RoundingMode.HALF_UP)
			}
			return field
		}
		set(value) {
			if (value != null) {
				giftsOfGold = (value.multiply(BigDecimal(Constants.OtherConfig.MONEY_TO_DB_DOUBLE))).toLong()
				field = value
			}
		}

}
